export function formatTimeDifference(timestamp) {
    const now = Date.now();
    const difference = now - timestamp;
    
	//算出各个时间单位的时间戳值
    const minute = 60 * 1000;
    const hour = 60 * minute;
    const day = 24 * hour;
    const month = 30 * day;
    const threeMonths = 3 * month;
    
    if (difference < minute) {
        return '一分钟内';
    } else if (difference < hour) {
        const minutes = Math.floor(difference / minute);
        return minutes+'分钟前';
    } else if (difference < day) {
        const hours = Math.floor(difference / hour);
        return hours+'小时前';
    } else if (difference < month) {
        const days = Math.floor(difference / day);
        return days+'天前';
    } else if (difference < threeMonths) {
        const months = Math.floor(difference / month);
        return months+'月前';
    } else {
        return null;
    }
}

export function goHome(){
	uni.showModal({
		title:"提示",
		content:"页面有误，将返回首页",
		showCancel:false,
		success:(res)=>{
			if(res.confirm){
				uni.reLaunch({
					url:"/pages/index/index"
				})
			}
		}
	})
}